package com.nbsystem.util;


import com.nbsystem.entity.ElcBlacklist;
import com.nbsystem.service.ElcBlacklistService;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.InitBinder;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;

@Component
public class MyWorldFilter {

    @Resource
    private ElcBlacklistService elcBlacklistService;

    private List<ElcBlacklist> elcBlacklists;


    public MyWorldFilter(){

    }


    //    对象创建后就执行的方法
    @PostConstruct
    public  void init(){

    }

    public  String  filterWorld(String world){
        elcBlacklists= elcBlacklistService.queryAll(new ElcBlacklist());
        for (ElcBlacklist elcBlacklist:elcBlacklists){
            world=world.replaceAll(elcBlacklist.getDetail(),"**");
        }
        return world;

    }


}

